import request from '@/utils/request'

// 常量
const api_name = '/admin/system/sysUser'

export default {
  // 列表
  getUserPageByQuery(page, limit, searchObj) {
    return request({
      url: `${api_name}/getUserPageByQuery/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },
  // 删除
  deleteUserById(id) {
    return request({
      url: `${api_name}/deleteUserById/${id}`,
      method: 'delete'
    })
  },
  // 添加
  saveUser(user) {
    return request({
      url: `${api_name}/saveUser`,
      method: 'post',
      data: user
    })
  },
  // 根据id查询
  getUserById(id) {
    return request({
      url: `${api_name}/getUserById/${id}`,
      method: 'post'
    })
  },
  // 修改
  updateUserById(user) {
    return request({
      url: `${api_name}/updateUserById`,
      method: 'post',
      data: user
    })
  },
  // 更改用户状态
  updateStatusById(id, status) {
    return request({
      url: `${api_name}/updateStatusById/${id}/${status}`,
      method: 'get'
    })
  },
  // 根据用户id查询用户已分配的角色
  getAssignedRoleListByUserId(userId) {
    return request({
      url: `${api_name}/getAssignedRoleListByUserId/${userId}`,
      method: 'get'
    })
  },

  // 分配角色
  assignRoleForUser(assignRoleVo) {
    return request({
      url: `${api_name}/assignRoleForUser`,
      method: 'post',
      data: assignRoleVo
    })
  }

}

